package com.baizhi.shane.shane.controller;

import com.baizhi.shane.common.base.Result;
import com.baizhi.shane.constant.ApiMapping;
import com.baizhi.shane.constant.TableNameMapping;
import com.baizhi.shane.shane.entity.ShaneLabel;
import com.baizhi.shane.shane.service.ShaneLabelService;
import com.baizhi.shane.shane.vo.*;
import com.baizhi.shane.sys.vo.IdVO;
import com.baizhi.shane.sys.vo.SuccessedOutVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 闻柏智
 * @date 2023/08/21 22:01:38
 */
@RestController
@RequestMapping(TableNameMapping.SHANE_LABEL)
@Api(tags="啥呢标签表")
public class ShaneLabelController {

    @Resource
    private ShaneLabelService shaneLabelService;

    @ApiOperation(value="新增一个标签", notes="新增一个标签")
    @PostMapping(value = ApiMapping.INSERT_ONE)
    public Result<OperOutVO> insertOne(
            @RequestBody LabelInsertInVO labelInsertInVO
    ) {
        OperOutVO operOutVO = shaneLabelService.insertOne(labelInsertInVO);
        return Result.OK(operOutVO);
    }

    @ApiOperation(value="分页查询标签列表", notes="分页查询标签列表")
    @PostMapping(value = ApiMapping.PAGE)
    public Result<IPage<ShaneLabel>> list(

    ) {

        return Result.OK(null);
    }
    @ApiOperation(value="通过关键字模糊查询标签列表", notes="通过关键字模糊查询标签列表")
    @PostMapping(value = ApiMapping.LIST_BY_CONTENT)
    public Result<List<LabelListByContentOutVO>> listByContent(
        @RequestBody LabelListByContentInVO labelListByContentInVO
    ) {
        List<LabelListByContentOutVO> labelListByContentOutVOList = shaneLabelService.listByContent(labelListByContentInVO);
        return Result.OK(labelListByContentOutVOList);
    }

    /**
     * 通过问题标签关系表的ID解除指定问题和标签的关联
     *
     * @Author 闻柏智
     * @Date 17:45 2024/1/15
     * @Param idVO
     * @return com.baizhi.shane.common.base.Result<com.baizhi.shane.sys.vo.SuccessedOutVO>
     **/
    @ApiOperation(value="通过问题标签关系表的ID解除指定问题和标签的关联", notes="通过问题标签关系表的ID解除指定问题和标签的关联")
    @PostMapping(value = ApiMapping.DELETE_ONE_LABEL_QUESTION_REL)
    public Result<SuccessedOutVO> deleteOneLabelQuestionRel(
            @RequestBody IdVO idVO
    ) {
        SuccessedOutVO successedOutVO = shaneLabelService.deleteOneLabelQuestionRel(idVO);
        return Result.OK(successedOutVO);
    }

    /**
     * 树形查询所有标签
     *
     * @Author 闻柏智
     * @Date 18:43 2024/1/15
     * @Param
     * @return com.baizhi.shane.common.base.Result<java.util.List<com.baizhi.shane.shane.vo.TreeLabelVO>>
     **/
    @ApiOperation(value="树形查询所有标签", notes="树形查询所有标签")
    @GetMapping(value = ApiMapping.TREE_LIST_ALL_LABEL)
    public Result<List<TreeLabelVO>> treeListAllLabel() {
        List<TreeLabelVO> treeLabelVOList = this.shaneLabelService.treeListAllLabel();
        return Result.OK(treeLabelVOList);
    }

    /**
     * 通过问题ID和标签ID关联问题和标签
     *
     * @Author 闻柏智
     * @Date 19:06 2024/1/15
     * @Param labelIdAndEntityIdVO
     * @return com.baizhi.shane.common.base.Result<com.baizhi.shane.sys.vo.SuccessedOutVO>
     **/
    @ApiOperation(value="通过问题ID和标签ID关联问题和标签", notes="通过问题ID和标签ID关联问题和标签")
    @PostMapping(value = ApiMapping.INSERT_ONE_QUESTION_LABEL_REL)
    public Result<SuccessedOutVO> insertOneQuestionLabelRel(@RequestBody LabelIdAndEntityIdVO labelIdAndEntityIdVO) {
        SuccessedOutVO successedOutVO = this.shaneLabelService.insertOneQuestionLabelRel(labelIdAndEntityIdVO);
        return Result.OK(successedOutVO);
    }


    @ApiOperation(value="初始化一级标签", notes="初始化一级标签")
    @PostMapping(value = "init_level_one")
    public Result<OperOutVO> initLevelOne(

    ) {
        OperOutVO operOutVO = shaneLabelService.initLevelOne();
        return Result.OK(operOutVO);
    }


}
